package com.example.demo.controller;

import com.example.demo.bean.EventData;
import com.google.gson.Gson;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @Author keke
 * @ClassName JsonCreatController
 * @Description
 * @Date 2020/01/14 20:04
 * @Version 1.0
 */
@RestController
public class JsonCreatController {
    @RequestMapping("/JsonCreat/creatEventData")
    public String creatEventData() {
        Gson gson = new Gson();

        EventData eventData = new EventData();
        eventData.setEventName("__xiaoXi");
        HashMap<String, Object> objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("room", "room");
        objectObjectHashMap.put("userID", "123");
        objectObjectHashMap.put("toUserID","456");
        objectObjectHashMap.put("info","456");
        eventData.setData(objectObjectHashMap);

        return gson.toJson(eventData);
    }
}
